
<h2 class="white"><?php echo $topic['Topic']['name']; ?> </h2>
<!-- <small>Criada por Fulano em <?php echo $topic['Topic']['creation_date']; ?></small> -->
<div class="topics view">

	<div class="posts">
		<?php foreach ($posts as $post) {?>
        
			<div class="media white">

				<a class="pull-left" href="#">
					<img class="media-object img-quad shadow" src="/img/users/<?php echo $post['User']['photo'] ?>">
				</a>

				<div class="media-body shadow" >
					<h5>
						<strong> <?php echo $post['User']['first_name'] . ' '. $post['User']['last_name'] ?> </strong>  
						<p><small><?php echo $post['Post']['creation_date'] ?></small></p>
                        
						<?php 
						if ( ($this->Community->userPart($this->User->id(),$topic['Topic']['community_id']) && $this->User->id() == $post['Post']['user_id']  && $post != $posts[0]) or $this->Community->userPartModerador($this->User->id(), $topic['Topic']['community_id']) ) { ?>
							<a data-toggle="modal" data-cmm='<?php echo $topic['Topic']['community_id'] ?>' data-topic='<?php echo $topic['Topic']['id'] ?>' data-post='<?php echo $post['Post']['id'] ?>' href="#box-modal" class="edit-coment btn-modal-edit-post"	><i class="glyphicon glyphicon-edit"></i> Editar</a>

							<form id="deletePostFrom" method="post" action="../posts/delete/<?php echo $topic['Topic']['community_id'] ?>/<?php echo $topic['Topic']['id'] ?>/<?php echo $post['Post']['id'] ?>">
								<a href="#" onclick="document.getElementById('deletePostFrom').submit();" class="delete-coment" ><i class="glyphicon glyphicon-delete"></i> Excluir</a>
							</form>
						<?php } ?>


						<?php //echo $this->Html->link(' <i class="glyphicon glyphicon-edit"></i> Editar', array('action' => '../posts/edit', $topic['Topic']['community_id'], $topic['Topic']['id'], $post['Post']['id']),array('escape'=>false ,'class' =>'edit-coment')); ?>

					</h5>
					<div class="content-feed-box margintop">
						<?php echo $post['Post']['description'];?>


						<?php //echo $this->Form->postLink('Deletar', array('action' => '../posts/delete', $topic['Topic']['community_id'], $topic['Topic']['id'], $post['Post']['id']), array('confirm' => 'Você tem certeza que quer excluir este Post?')); ?>
					</div>

					<!-- model adicioanr topico -->
	
								<div class="modal fade" id="box-modal">
								  <div class="modal-dialog">
								    <div class="modal-content">
								      <div class="modal-header">
								        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
								        <h4 class="modal-title"></h4>
								      </div>
								      <div class="modal-body modal-body-add-tpc">
								       
								      </div>
								      <div class="modal-footer">
								    
								      </div>
								    </div><!-- /.modal-content -->
								  </div><!-- /.modal-dialog -->
								</div><!-- /.modal -->

				</div>
			</div>
		<?php } ?>

		<div class="form-coment" id="coment">
			<p><small>Dê sua opinião  </small></p>
			<a href="#coment" onclick="openBoxComent()" class="btn btn-primary open-box-coment">Comentar</a>

			<div class="form">
				<?php echo $this->Form->create('Post', array('controller'=>'posts','action'=> 'add/'.$this->Community->getId($cmm_url))); ?>
					<?php
						echo $this->Form->input('description',array('label'=>false,'id'=>'texto','class'=>'ckeditor'));
						//echo $this->Form->input('status', array('type' => 'text'));
			            echo $this->Form->input('user_id', array('type' => 'hidden','value'=> $this->User->id()));
						//echo $this->Form->input('creation_date');
						echo $this->Form->input('topic_id', array('type' => 'hidden','value'=>$topic['Topic']['id']));	

						echo $this->Form->end(array('label'=>'Comentar','class'=>"btn btn-primary pull-left"));

					?>	
					<a href="#" onclick="closeBoxComent()" class="btn btn-danger">Cancelar</a>
			</div>		
		</div>

	</div>
</div>